package com.cailu.rabmq.sender.sender;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.cailu.common.constant.SenderConfTopicCommon;

/**
 * @author cailu
 * @filename SenderConfTopicTemplate
 * @description Topic转发模式
 * @date 2020/3/31 15:34
 */
@Component
public class SenderConfTopicTemplate {

	@Autowired
	private AmqpTemplate template;

	/**
	 * 功能描述
	 * @param str 内容
	 * @return void
	 * @author cailu
	 * @date 2020/4/1 14:14
	 */
	public void sendTopictemplate(String str) {
		if ("".equals(str) || str == null) {
			template.convertAndSend(SenderConfTopicCommon.DIRECT_TOPIC_MESSAGE_EXCHANGE,
					SenderConfTopicCommon.DIRECT_TOPIC_MESSAGE, "hello,Topic转发模式");
		} else {
			template.convertAndSend(SenderConfTopicCommon.DIRECT_TOPIC_MESSAGE_EXCHANGE,
					SenderConfTopicCommon.DIRECT_TOPIC_MESSAGE, str);
		}

	}

	/**
	 * 功能描述  指定的转发到目标 路由器
	 * @param str 内容
	 * @return void
	 * @author cailu
	 * @date 2020/4/1 14:14
	 */
	public void sendTopicToMestemplate(String str) {
		if ("".equals(str) || str == null) {
			template.convertAndSend(SenderConfTopicCommon.DIRECT_TOPIC_MESSAGE_EXCHANGE,
					SenderConfTopicCommon.DIRECT_TOPIC_TO_MESSAGE, "hello,Topic转发模式");
		} else {
			template.convertAndSend(SenderConfTopicCommon.DIRECT_TOPIC_MESSAGE_EXCHANGE,
					SenderConfTopicCommon.DIRECT_TOPIC_TO_MESSAGE, str);
		}

	}


}
